package com.kelvem.saas.workbanch.core.manager.dao;

import com.kelvem.saas.workbanch.fsm.anno.entity.RegisterDao;
import com.kelvem.saas.workbanch.fsm.dao.BaseDao;
import com.kelvem.saas.workbanch.core.manager.model.BizPageEntity;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 实体业务Dao
 *
 * @author kelvem
 * @version 1.0
 */
@Mapper
@RegisterDao(entityClass= BizPageEntity.class)
@Repository
public interface BizPageDao extends BaseDao<BizPageEntity> {
    
    @Select("SELECT t.* FROM biz_page t WHERE t.id=#{id}")
    @Results({
            @Result(column="id",property="id"),
            //这里的column="group_id"是将列值的参数传给GroupMapper的queryGroupByGid方法
            @Result(column="id",property="bizPageDomList",
                    many=@Many(select="com.kelvem.saas.workbanch.core.manager.dao.BizPageDomDao.queryBizPageDomList",
                            fetchType= FetchType.EAGER)),
            @Result(column="id",property="bizPageActionList",
                    many=@Many(select="com.kelvem.saas.workbanch.core.manager.dao.BizPageActionDao.queryBizPageActionList",
                            fetchType= FetchType.EAGER)),
    })
    BizPageEntity getBizPageById(Long id);

    @Select("select p.* from biz_page p inner join sys_org_mapping_menu om on p.id = om.menu_id where om.org_id = #{orgId}")
    List<BizPageEntity> queryMenuByOrgId(Long orgId);
}
